////////////////////////////////////////////////////////////////////////////////////////////////////
/// @file   CollabRCBotUnitTests\TestDiffLine.h
///
/// @brief  Defines the test suite for CollabRC::Bot::DiffLine
////////////////////////////////////////////////////////////////////////////////////////////////////

#include <cxxtest/TestSuite.h>
#include "../CollabRCBot/DiffLine.h"

class TestDiffLine : public CxxTest::TestSuite
{
private:
    QString m_1, m_2, m_3, m_4;
public:
    inline TestDiffLine():m_1("1"),m_2("2"),m_3("3"),m_4("4") { };

    void TestFailedNonDiff()
    {
        // Having both added and removed missing is illegal
        TS_ASSERT_THROWS(CollabRC::Bot::DiffLine invalid("", ""), const CollabRC::IllegalArgumentException&);
        TS_ASSERT_THROWS_NOTHING(CollabRC::Bot::DiffLine notInvalid("", "a"));
        TS_ASSERT_THROWS_NOTHING(CollabRC::Bot::DiffLine notInvalid2("a", ""));
    }

    void TestGetAddedAndRemovedLine()
    {
        CollabRC::Bot::DiffLine line(m_1, m_2);
        TS_ASSERT_EQUALS(m_1, line.GetRemovedLine());
        TS_ASSERT_EQUALS(m_2, line.GetAddedLine());
    }

    void TestAssignmentOperator()
    {
        CollabRC::Bot::DiffLine line(m_1, m_2);
        CollabRC::Bot::DiffLine line2(m_3, m_4);

        TS_ASSERT_THROWS_NOTHING(line = line2);
        TS_ASSERT_EQUALS(m_1, "1"); 
        TS_ASSERT_EQUALS(m_2, "2");
        TS_ASSERT_EQUALS(m_3, "3");
        TS_ASSERT_EQUALS(m_4, "4");
        TS_ASSERT_EQUALS(line.GetRemovedLine(), "3");
        TS_ASSERT_EQUALS(line.GetAddedLine(), "4");
        TS_ASSERT_EQUALS(line2.GetRemovedLine(), "3");
        TS_ASSERT_EQUALS(line2.GetAddedLine(), "4");
    }

    void TestCopyConstructor()
    {
        CollabRC::Bot::DiffLine line(m_1, m_2);
        CollabRC::Bot::DiffLine line2(line);
        TS_ASSERT_EQUALS(line.GetRemovedLine(), line2.GetRemovedLine());
        TS_ASSERT_EQUALS(line.GetAddedLine(), line2.GetAddedLine());
    }

};